{extend name="common:frm_base" /}
{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="nick_name" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">志愿者审核</label>
                    <div class="layui-input-block">
                        <select name="status">
                            <option value="all">请选择状态</option>
                            <option value="0">审核中</option>
                            <option value="1">审核通过</option>
                            <option value="2">审核不通过</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">组织审核</label>
                    <div class="layui-input-block">
                        <select name="o_status">
                            <option value="all">请选择状态</option>
                            <option value="0">审核中</option>
                            <option value="1">审核通过</option>
                            <option value="2">审核不通过</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">实践站</label>
                    <div class="layui-input-block">
                        <select name="site_id">
                            <option value="all">请选择实践站</option>
                            {volist name="site" id="val"}
                            <option value="{$val.id}">{$val.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">实践所</label>
                    <div class="layui-input-block">
                        <select name="site_ids">
                            <option value="all">请选择实践所</option>
                            {volist name="site_list" id="val"}
                            <option value="{$val.id}">{$val.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>
        <style>
            .layui-table-cell{
                height:40px;
                line-height:40px;
            }
        </style>
        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <button name="export" class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-export">导出</button>
                <button name="export_all" class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-export-all">导出全部</button>
            </div>

            <table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>
            <script type="text/html" id="imgTpl">
                <img style="display: inline-block; width: 40px; height: 100%;" src= {{ d.head_pic }}>
            </script>
            <script type="text/html" id="addTpl">
                {{#  if(d.is_add == 1){ }}
                <span class="layui-btn layui-btn-xs">是</span>
                {{#  } else{ }}
                <span class="layui-btn layui-btn-xs layui-btn-warm">否</span>
                {{#  } }}
            </script>
            <script type="text/html" id="partyTpl">
                {{#  if(d.is_party == 1){ }}
                <span class="layui-btn layui-btn-xs">是</span>
                {{# }else{ }}
                <span class="layui-btn layui-btn-xs layui-btn-warm">否</span>
                {{#  } }}
            </script>

            <script type="text/html" id="oStatusTpl">
                {{#  if(d.o_status == 1){ }}
                <span class="layui-btn layui-btn-xs">审核通过</span>
                {{#  } else if(d.o_status == 2){ }}
                <span class="layui-btn layui-btn-xs layui-btn-warm">审核不通过</span>
                {{# }else{ }}
                <span class="layui-btn layui-btn-xs layui-btn-warm">审核中</span>
                {{#  } }}
            </script>
            <script type="text/html" id="table-useradmin-webuser">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i
                        class="layui-icon layui-icon-edit"></i>编辑</a>
            </script>
        </div>
    </div>
</div>

<script>


    layui.config({
        base: '__LAYUIADMIN__/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table;

        //监听搜索
        form.on('submit(LAY-user-front-search)', function (data) {
            var field = data.field;
            //执行重载
            table.reload('LAY-user-manage', {
                where: field
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });

        //监听搜索
        form.on('submit(LAY-user-front-export)', function (data) {
            var field = data.field;
            window.location="/admin/volunteer/export/id/{$id}/limit/30/page/"+$(".layui-laypage-em").next().html()+"/code/"+field.code;
        });

        form.on('submit(LAY-user-front-export-all)', function (data) {
            var field = data.field;
            window.location="/admin/volunteer/export/type/all/id/{$id}/code/"+field.code;
        });

        //用户管理
        table.render({
            elem: '#LAY-user-manage'
            , url: "{:url('party/ajaxIndex')}" //模拟接口
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'nickname', title: '昵称', minWidth: 100, align:'center'}
                , {field: 'realname', title: '姓名', minWidth: 80, align: 'center'}
                , {field: 'site', title: '站点', minWidth: 80, align: 'center'}
                , {field: 'team', title: '服务队', minWidth: 80, align: 'center'}
                , {field: 'id_card', title: '身份证号', minWidth: 80, align: 'center'}
                , {field: 'skill', title: '服务类型', minWidth: 80, align: 'center'}
                , {field: 'is_party', title: '是否党员', minWidth: 50, align: 'center',toolbar: '#partyTpl'}
                , {field: 'duration', title: '服务时长', minWidth: 50, align: 'center'}
                , {field: 'duration1', title: '活动时长', minWidth: 50, align: 'center'}
                , {field: 'status', title: '状态', minWidth: 80, align: 'center'}
                , {field: 'o_status', title: '组织状态', minWidth: 80, align: 'center',toolbar: '#oStatusTpl'}
                , {field: 'is_add', title: '是否发布', minWidth: 50, align: 'center',toolbar: '#addTpl'}
                , {field: 'create_time', title: '添加时间', sort: true,}
            ]]
            , method: 'post'
            , page: true
            , limit: 30
            , height: 'full-180'
            , text: '对不起，加载出现异常！'
        });

        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
            var type = $(this).data('type');
            var url = "";
            if (type == 'add') {
                url = "{:url('Role/add')}";
            }
            active[type] ? active[type].call(this, url, table) : '';
        });
    });
</script>
</body>
</html>
{/block}
